package com.sqllog.admin.sql.service;

import com.sqllog.admin.framework.tools.SequenceUtil;
import com.sqllog.admin.sql.entity.CanalClientConsumerLog;
import com.sqllog.admin.sql.mapper.CanalClientConsumerLogMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * TODO
 *
 * @author chennengcheng
 * @date 2022-02-09 11:21
 * @remark
 */

@Service
public class CanalClientConsumerLogService {

    @Resource
    private CanalClientConsumerLogMapper canalClientConsumerLogMapper;

    public int saveCanalClientConsumerLog(String clientId, String content) {
        CanalClientConsumerLog canalClientConsumerLog = new CanalClientConsumerLog();
        canalClientConsumerLog.setId(SequenceUtil.makeStringId());
        canalClientConsumerLog.setClientId(clientId);
        canalClientConsumerLog.setContent(content);
        canalClientConsumerLog.setCreateDate(new Date());
        canalClientConsumerLog.setUpdateDate(new Date());
        canalClientConsumerLog.setDelFlag("0");
        return canalClientConsumerLogMapper.insert(canalClientConsumerLog);
    }

    public List<CanalClientConsumerLog> selectByClientId(String clientId) {
        return canalClientConsumerLogMapper.selectByClientId(clientId);
    }
}
